﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using RedDragon.RBAC.API.Application.Common.User;
using T.Common.Domain.Common;

namespace RedDragon.RBAC.API.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class UsersController : ControllerBase
    {
        private readonly IMediator mediator;
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="mediator">mediator</param>
        public UsersController(IMediator mediator)
        {
            this.mediator = mediator;
        }

        /// <summary>
        /// 用户添加注册
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Result> addUsers(AddUsersCommand cmd)
        {
            return await mediator.Send(cmd);
        }


        /// <summary>
        /// 用户登录
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Result> Login(AddLoginCommand cmd)
        {
            return await mediator.Send(cmd);
        }

        /// <summary>
        /// 用户列表
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Result> ShowUsers(QueryUserCommand cmd)
        {
            return await mediator.Send(cmd);
        }
    }
}
